package cn.tedu._04mybatis.mapper;

import cn.tedu._04mybatis.pojo.entity.Comment;
import cn.tedu._04mybatis.pojo.entity.Weibo;
import cn.tedu._04mybatis.pojo.vo.CommentVO1;
import cn.tedu._04mybatis.pojo.vo.CommentVO2;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CommentMapper {
    @Insert("INSERT INTO comment (content,created,user_id,weibo_id) VALUES (#{content},#{created},#{userId},#{weiboId})")
    int insertComment(Comment comment);

    @Delete("DELETE FROM comment WHERE id=#{id}")
    int deleteById(Long id);

    @Update("UPDATE comment SET id=#{id},content=#{content},created=#{created},user_id=#{userId},weibo_id=#{weiboId} WHERE id=#{id}")
    int updateById(Comment comment);

    @Select("SELECT content,user_id userId,weibo_id weiboId FROM comment WHERE id=#{id}")
    CommentVO1 selectCommentById(Long id);

    @Select("SELECT content,user_id userId FROM comment WHERE user_id=#{userId}")
    List<CommentVO2> selectCommentsById(Long userId);
}
